import * as types from '../../action-type'

const userMutations = {
    [types.SET_PERMISSION](state, payload) {
        // 设置权限
        state.hasPermission = payload;
    },
    [types.SET_USER](state, payload) {
        // 设置用户信息
        console.log('payload is:', payload);
        state.token = payload.token;
        state.username = payload.username;
        state.authList = payload.authList;

        if (payload.token) { // 存储token
            localStorage.setItem('token', payload.token);
        }
    },
    [types.SET_MENU_PERMISSION](state, payload) {
        state.menuPermission = payload;
    }
}

export default userMutations;